// 导入axios
import request from '@/utils/request.js'

/**
 * 用户列表
 */

// 登录

export const getlogin = (data) => {
  return request({
    method: 'POST',
    url: '/frame/login',
    data
  })
}

// 获取用户数据
export const getuser = (data) => {
  // console.log(data)  可以检查是否有参数
  return request({
    method: 'GET',
    url: 'users',
    params: data
  })
}
// 添加用户
export const adduser = (data) => {
  console.log(data)
  return request({
    method: 'POST',
    url: 'users',
    data
  })
}
// 调取用户的简单数据
export const simpleuser = (Query) => {
  return request({
    method: 'GET',
    url: 'users/simple',
    params: Query
  })
}
// 请求用户详细数据
export const detaileduser = (id, data) => {
  return request({
    method: 'GET',
    url: `users/${id}`,
    params: data
  })
}

// 编辑用户
export const edituser = (id, data) => {
  return request({
    method: 'PUT',
    url: `users/${id}`,
    data
  })
}
// 删除用户
export const deleteuser = (id) => {
  return request({
    method: 'DELETE',
    url: `users/${id}`
  })
}

// 获取菜单列表数据
export const addmenu = () => {
  return request({
    method: 'GET',
    url: 'menus'
  })
}
// 获取详细菜单数据
export const detailsmenu = (id) => {
  return request({
    method: 'GET',
    url: `menus/${id}`
  })
}
// 添加菜单数据
export const tianjiamenu = (data) => {
  // console.log(data)
  return request({
    method: 'POST',
    url: 'menus',
    data
  })
}

// 编辑菜单数据
export const editmenu = (id, data) => {
  console.log(id, data)
  return request({
    method: 'PUT',
    url: `menus/${id}`,
    data
  })
}
// 删除菜单数据

export const deletmenu = (id) => {
  console.log(id)
  return request({
    method: 'DELETE',
    url: `menus/${id}`
  })
}

// 获取 permissions 权限列表
export const getpermiss = (query) => {
  return request({
    method: 'GET',
    url: 'permissions',
    params: query
  })
}
// 获取 permissions 新增权限列表数据
export const addpermiss = (body) => {
  return request({
    method: 'POST',
    url: 'permissions',
    data: body
  })
}
// 获取 permissions 简单权限数据列表
export const simplepermiss = (query) => {
  return request({
    method: 'GET',
    url: ' permissions/simple',
    params: query
  })
}
